package com.itheima.mString;

import java.util.Scanner;

/*
     以字符串的形式从键盘录入学生信息,例如:"张三,23",从该字符串中切割出有效数据,封装为Student学生对象
 */
public class StringDemo06 {
    public static void main(String[] args) {
        //2.键盘录入一个字符串
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学生信息:");
        String information = sc.nextLine();
        //3.根据逗号切割字符串,得到(张三)(23)
        String[] student = information.split(",");
        //4.新建对象
        Student student1 = new Student(student[0], student[1]);
        //5.调用对象getXxx方法,取出数组数据并打印
        System.out.println("姓名为:" + student1.getName());
        System.out.println("年龄为:" + student1.getAge());
    }
}
